class Solution {
    public int takeAttendance(int[] records) {
        int l=0,r=records.length-1;
        while(l<r){
            int mid=l+(r-l)/2;
            if(records[mid]==mid) l=mid+1;
            else r=mid;
        }
        return l==records[l]?l+1:l;
    }
}